﻿using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;
namespace SIS.BLL
{
    /// <summary>
    /// The EmployeeTimeSheetTableManager class is responsible for managing BO.EmployeeTimeSheetTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class EmployeeTimeSheetTableManager
    {
        #region "Public Methods"

        /// <summary>
        /// Gets a list with all EmployeeTimeSheetTable objects in the database.
        /// </summary>
        /// <returns>A list with all EmployeeTimeSheetTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static EmployeeTimeSheetTableList GetList()
        {
            return EmployeeTimeSheetTableDB.GetList();
        }

        public static EmployeeTimeSheetTableList GetList(int SchoolKey, string EmployeeProfileKey, DateTime StartDate, DateTime EndDate)
        {
            return EmployeeTimeSheetTableDB.GetList(SchoolKey, EmployeeProfileKey, StartDate, EndDate);
        }

        public static EmployeeTimeSheetTableList GetListByUserAccount(int SchoolKey, int UserAccountKey, DateTime StartDate, DateTime EndDate)
        {
            return EmployeeTimeSheetTableDB.GetListBySchoolNUserAccount(SchoolKey, UserAccountKey, StartDate, EndDate);
        }
        /// <summary>
        /// Gets a single EmployeeTimeSheetTable from the database without its data.
        /// </summary>
        /// <param name="employeeAttandanceKey">The EmployeeAttandanceKey of the EmployeeTimeSheetTable in the database.</param>
        /// <returns>A EmployeeTimeSheetTable object when the EmployeeAttandanceKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static EmployeeTimeSheetTable GetItem(long employeeAttandanceKey)
        {
            return GetItem(employeeAttandanceKey, false);
        }

        /// <summary>
        /// Gets a single EmployeeTimeSheetTable from the database.
        /// </summary>
        /// <param name="employeeAttandanceKey">The EmployeeAttandanceKey of the EmployeeTimeSheetTable in the database.</param>
        /// <param name="getEmployeeTimeSheetTableRecords">Determines whether to load all associated EmployeeTimeSheetTable records as well.</param>
        /// <returns>
        /// A EmployeeTimeSheetTable object when the EmployeeAttandanceKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static EmployeeTimeSheetTable GetItem(long employeeAttandanceKey, bool getEmployeeTimeSheetTableRecords)
        {
            EmployeeTimeSheetTable myEmployeeTimeSheetTable = EmployeeTimeSheetTableDB.GetItem(employeeAttandanceKey);
            return myEmployeeTimeSheetTable;
        }

        /// <summary>
        /// Saves a EmployeeTimeSheetTable in the database.
        /// </summary>
        /// <param name="myEmployeeTimeSheetTable">The EmployeeTimeSheetTable instance to save.</param>
        /// <returns>The new EmployeeAttandanceKey if the EmployeeTimeSheetTable is new in the database or the existing EmployeeAttandanceKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static long Save(EmployeeTimeSheetTable myEmployeeTimeSheetTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                long EmployeeTimeSheetKey = EmployeeTimeSheetTableDB.Save(myEmployeeTimeSheetTable);

                //  Assign the EmployeeTimeSheetTable its new (or existing EmployeeAttandanceKey).
                myEmployeeTimeSheetTable.EmployeeTimeSheetKey = EmployeeTimeSheetKey;

                myTransactionScope.Complete();

                return EmployeeTimeSheetKey;
            }
        }

        /// <summary>
        /// Deletes a EmployeeTimeSheetTable from the database.
        /// </summary>
        /// <param name="myEmployeeTimeSheetTable">The EmployeeTimeSheetTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(EmployeeTimeSheetTable myEmployeeTimeSheetTable)
        {
            return EmployeeTimeSheetTableDB.Delete(myEmployeeTimeSheetTable.EmployeeTimeSheetKey);
        }

        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(long EmployeeAttandanceKey)
        {
            return EmployeeTimeSheetTableDB.Delete(EmployeeAttandanceKey);
        }

        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool UpdateTimeOut(long EmployeeAttandanceKey, DateTime TimeOut)
        {
            return EmployeeTimeSheetTableDB.UpdateTimeOut(EmployeeAttandanceKey, TimeOut);
        }

        #endregion
    }
}
